package com.jmxcfc.blfsc.common.common.response;

import com.jmxcfc.blfsc.common.common.enums.BaseErrorEnum;
import com.jmxcfc.blfsc.common.common.enums.ProcessStateEnum;
import lombok.Data;
import lombok.ToString;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

@Data
@ToString
public class HeaderResponse {
    /**
     * 请求业务号(上游系统传)
     */
    private String requestNo;


    /**
     * 请求流水号(基础服务生成)
     * 批量模式中(比如短信):代指:请求厂商批次号【唯一标识这一批次】
     * 单笔模式(签章):代指:请求厂商的交易流水号【唯一标识这笔请求】
     */
    private String serialSeq;


    /**
     * 处理状态
     */
    private ProcessStateEnum processState;


    /**
     * 响应结果
     */
    private String resCode;

    /**
     * 响应消息
     */
    private String resMessage;


    /**
     * 响应时间,格式:yyyy-MM-dd HH:mm:ss
     */
    private String resTime;


    public HeaderResponse(String resCode, String resMessage, String resTime) {
        this.resCode = resCode;
        this.resMessage = resMessage;
        this.resTime = resTime;
    }

    public HeaderResponse(String resCode, String resMessage) {
        this.resCode = resCode;
        this.resMessage = resMessage;
    }

    public HeaderResponse(ProcessStateEnum processStateEnum,BaseErrorEnum baseErrorEnum, String resMessage) {
        this.processState = processStateEnum;
        this.resCode = baseErrorEnum.getValue();
        this.resMessage = resMessage;
    }

    public HeaderResponse(BaseErrorEnum errorEnum) {
        this.resCode = errorEnum.getValue();
        this.resMessage = errorEnum.getMsg();
        this.resTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

    public HeaderResponse() {
    }
}
